/* 
 * File:   ServerSocketImpl.cpp
 * Author: ariel
 * 
 * Created on December 4, 2009, 2:10 AM
 */

#include "ServerSocketImpl.h"
#include "SocketException.h"
bool ServerSocketImpl::parche = false;

void ServerSocketImpl::startListen() {
    ServerSocket * socket = NULL;
    EngineFacadeThread* facadeRunnable=NULL;
    while(this->running) {
        try {
            socket=new ServerSocket();
            server.accept(*socket);
            facadeRunnable = new EngineFacadeThread(engine,socket);
            Thread thread(facadeRunnable);
            thread.start();
        } catch(SocketException& exception) {
            delete(socket);
            this->running=false;
            std::cout << "No se puede escuchar en el puerto" << std::endl;
        }
    }
}

void ServerSocketImpl::run() {
    startListen();
}

ServerSocketImpl::~ServerSocketImpl() {
    
}



